home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 001-100 / 001-025 / 001 / palette / palette.c < prev    next >
C/C++ Source or Header  |  1995-03-17  |  16KB  |  451 lines

  1. /***********************************************************************
  2. *  palette.c
  3. *     This program is useful for designing color palettes.
  4. * It may be used stand-alone (I would be setting the 'default map',
  5. * if preferences had a complete color map...), or you can use it
  6. * as a subroutine with minor modifications.
  7. *     One of the unique features of this program is that it prints
  8. * the hex value of the selected color, so you use it to generate
  9. * numeric values for use in programs.
  10. *     (c) 1985 by Charlie Heath of Microsmiths, this program is in
  11. * the public domain.  Not to be used commercially without permission
  12. * from MicroSmiths.
  13. ***********************************************************************/
  14.  
  15. #include <exec/types.h>
  16. #include <exec/devices.h>
  17. #include <intuition/intuition.h>
  18.  
  19. #include <graphics/gels.h>
  20. #include <graphics/copper.h>
  21. #include <graphics/regions.h>
  22. #include <devices/keymap.h>
  23.  
  24. #define I_REV   29
  25. #define G_REV   29
  26.  
  27. struct IntuitionBase *IntuitionBase;
  28. struct GfxBase  { int b; } *GfxBase;
  29.  
  30. #define FAST register      /* Register type variable  */
  31.  
  32. #define DPTH 5       /* Raster dimensions */
  33. #define WDTH 320
  34. #define HGHT 200
  35.  
  36. #define NL 0
  37.  
  38. #define BCOL 1          /* Background color for menus, etc   */
  39.  
  40. #define CTSIZ  32       /* In spite of myself, color table size   */
  41.  
  42. /* Font Descriptor   */
  43. struct TextAttr MyFont = {"topaz.font",TOPAZ_EIGHTY,FS_NORMAL,FPF_ROMFONT };
  44.  
  45. /* Used to open a Screen   */
  46. struct NewScreen NewScreen = {
  47.    0,0,WDTH,HGHT,DPTH,       /* Left,Top,Width,Height,Depth    */
  48.    1,2,NL,                   /* DetailPen, BlockPen, ViewModes */
  49.    CUSTOMSCREEN,&MyFont,     /* Type, Font  */
  50.    (UBYTE *)"MicroSmiths Palette Tool",  /* Title       */
  51.    NL,NL };                  /* Gadgets, BitMap  */
  52.  
  53. /* Used to open a Window   */
  54. struct NewWindow NewWindow = {
  55.    0,0,WDTH,HGHT, /* LeftEdge,TopEdge,Width,Height */
  56.    8,BCOL,         /* DetailPen,BlockPen     */
  57.    MOUSEBUTTONS | MOUSEMOVE | MENUVERIFY | MENUPICK | GADGETUP |
  58.       GADGETDOWN | CLOSEWINDOW | ACTIVEWINDOW,
  59.    SMART_REFRESH | REPORTMOUSE | ACTIVATE | BACKDROP | BORDERLESS, /*Flags*/
  60.    NL,NL,NL,       /* FirstGadget, CheckMark, Title  */
  61.    NL,             /* MUST SET SCREEN AFTER OPENSCREEN!!! */
  62.    NL,             /* BitMap    */
  63.    100,60,32767,32767, /* MinW, MinH, MaxW, MaxH */
  64.    CUSTOMSCREEN };     /* Type   */
  65.  
  66.  
  67. /****    Variables Initialized by init_program()  **********/
  68. struct Screen   *p_S;
  69. struct Window   *p_W;
  70. struct ViewPort *p_Vp;
  71. struct ColorMap *p_Co;
  72. USHORT *p_ct;           /* Color table as words */
  73.  
  74. USHORT default_color[CTSIZ];     /* Save a copy of the defaults   */
  75.  
  76.  
  77. /****************************************************************
  78. * init_program()
  79. *
  80. *     Opens screen and full-sized window for program.
  81. *
  82. *     Initializes handles p_S,p_W
  83. *
  84. *  See also: clear_program()                                     */
  85. init_program()
  86. {
  87. FAST int i;
  88.  
  89.    if ( ! (IntuitionBase = (struct IntuitionBase *)
  90.      OpenLibrary("intuition.library",I_REV)) ||
  91.       ! (GfxBase =(struct GfxBase *)OpenLibrary("graphics.library",G_REV)) )
  92.          exit(20);
  93.  
  94.    if ( ! (p_S =(struct Screen *)OpenScreen(&NewScreen)) ) {
  95.       printf("Can't Open Screen! Get More Mem!\n");
  96.       exit(21);
  97.       }
  98.  
  99.    NewWindow.Screen = p_S;   /* NEED TO SET SCREEN!!! */
  100.  
  101.    if ( ! (p_W =(struct Window *)OpenWindow(&NewWindow)) ) {
  102.       CloseScreen(p_S);
  103.       printf("This is not good.\n");
  104.       exit(22);
  105.       }
  106.  
  107.    p_Vp = (struct ViewPort *)ViewPortAddress(p_W);
  108.  
  109.    p_Co = (struct ColorMap *)GetColorMap(CTSIZ);
  110.    p_ct = (USHORT *)p_Co->ColorTable;
  111.  
  112.    for ( i=0; i<CTSIZ; i++)
  113.       default_color[i] = p_ct[i];
  114.    default_color[0] = 0x20f; default_color[1] = 0xfff;
  115.    default_color[2] = 0x000; default_color[3] = 0xe30;
  116.    set_defmap();
  117. }
  118.  
  119.  
  120.  
  121. /*************************************************
  122. * clear_program
  123. *
  124. *  Cleans up what was allocated by init_program.
  125. *************************************************/
  126. clear_program()
  127. {
  128.    FreeColorMap(p_Co);
  129.    CloseWindow(p_W);
  130.    CloseScreen(p_S);
  131.    CloseLibrary(GfxBase);
  132.    CloseLibrary(IntuitionBase);
  133. }
  134.  
  135.  
  136. /****************************************************************
  137. * set_defmap()
  138. *    This routine sets up a 'default' color map.  It assumes
  139. * you have initialized the variable p_ct to point to a color
  140. * table, and that default_color has the colors you want.       */
  141. set_defmap()
  142. {
  143. FAST int i;
  144.  
  145.    for (i=0; i<CTSIZ ; i++)
  146.       *(p_ct+i) = default_color[i];
  147.  
  148.    set_cmap();
  149. }
  150.  
  151.  
  152.  
  153. /****************************************************************
  154. * set_cmap()
  155. *     This routine loads an updated p_ct color table into the
  156. * viewport.  You must have initialized the variables p_ct and
  157. * p_Vp to point at color table and ViewPort                     */
  158. set_cmap()
  159. {
  160.    LoadRGB4(p_Vp,p_ct,CTSIZ);
  161. }
  162.  
  163.  
  164. /***   palette modifier routines follow    ************************/
  165.  
  166. #define PLX 165      /* Palette Window Size  */
  167. #define PLY 132
  168.  
  169. #define PGAD 0             /* You can offset the gadgets here  */
  170. #define PGHI   PGAD+CTSIZ  /* Offset frm color selectors       */
  171.  
  172. struct IntuiText rtxt = {2,2,JAM1,-9,2,NL,(UBYTE *)"R",NL};
  173. struct IntuiText gtxt = {2,2,JAM1,-9,2,NL,(UBYTE *)"G",NL};
  174. struct IntuiText btxt = {2,2,JAM1,-9,2,NL,(UBYTE *)"B",NL};
  175.  
  176. struct Image    r_img, g_img, b_img;
  177. struct PropInfo r_prop,g_prop,b_prop;
  178.  
  179. struct Gadget blue_gad = {
  180.    NL, 17,112, 90,11, GADGHCOMP, GADGIMMEDIATE | RELVERIFY,
  181.    PROPGADGET,(APTR)&b_img, NL,
  182.    &btxt, NL,(APTR)&b_prop, PGHI+3, NL };
  183.  
  184. struct Gadget green_gad = {
  185.    &blue_gad, 17,97, 90,11, GADGHCOMP, GADGIMMEDIATE | RELVERIFY,
  186.    PROPGADGET,(APTR)&g_img, NL,
  187.    >xt, NL,(APTR)&g_prop, PGHI+4, NL };
  188.  
  189. struct Gadget red_gad = {
  190.    &green_gad, 17,82, 90,11, GADGHCOMP, GADGIMMEDIATE | RELVERIFY,
  191.    PROPGADGET,(APTR)&r_img, NL,
  192.    &rtxt, NL,(APTR)&r_prop, PGHI+5, NL };
  193.  
  194. struct IntuiText oktxt = {3,2,JAM2,8,2,NL,(UBYTE *)" OK ",NL};
  195. struct IntuiText cntxt = {3,2,JAM2,0,2,NL,(UBYTE *)"Cancel",NL};
  196. struct IntuiText retxt = {3,2,JAM2,4,2,NL,(UBYTE *)"Reset",NL};
  197.  
  198. struct IntuiText mstxt={2,2,JAM1,0,0,NL,(UBYTE *)"MicroSmiths Palette",NL};
  199.  
  200. char frog[] = "hex";
  201. struct IntuiText hxtxt = {3,2,JAM2,136,31,NL,(UBYTE *)frog,NL};
  202.  
  203. struct Gadget re_gad = {
  204.    &red_gad, 110,112, 54,11, GADGHCOMP, RELVERIFY,
  205.    BOOLGADGET, NL, NL,
  206.    &retxt, NL,NL, PGHI+2, NL };
  207. struct Gadget cn_gad = {
  208.    &re_gad, 110,97, 54,11, GADGHCOMP, RELVERIFY,
  209.    BOOLGADGET, NL, NL,
  210.    &cntxt, NL,NL, PGHI+1, NL };
  211. struct Gadget ok_gad = {
  212.    &cn_gad, 110,82, 54,11, GADGHCOMP, RELVERIFY,
  213.    BOOLGADGET, NL, NL,
  214.    &oktxt, NL,NL, PGHI, NL };
  215.  
  216. struct Image m3C[CTSIZ] = {
  217.    {0,0,16,16,1, NL ,0,0,NL },   /* Colors   */
  218.    {0,0,16,16,1, NL ,0,1,NL },
  219.    {0,0,16,16,1, NL ,0,2,NL },
  220.    {0,0,16,16,1, NL ,0,3,NL },
  221.    {0,0,16,16,1, NL ,0,4,NL },
  222.    {0,0,16,16,1, NL ,0,5,NL },
  223.    {0,0,16,16,1, NL ,0,6,NL },
  224.    {0,0,16,16,1, NL ,0,7,NL },
  225.    {0,0,16,16,1, NL ,0,8,NL },
  226.    {0,0,16,16,1, NL ,0,9,NL },
  227.    {0,0,16,16,1, NL ,0,10,NL },
  228.    {0,0,16,16,1, NL ,0,11,NL },
  229.    {0,0,16,16,1, NL ,0,12,NL },
  230.    {0,0,16,16,1, NL ,0,13,NL },
  231.    {0,0,16,16,1, NL ,0,14,NL },
  232.    {0,0,16,16,1, NL ,0,15,NL },
  233.    {0,0,16,16,1, NL ,0,16,NL },
  234.    {0,0,16,16,1, NL ,0,17,NL },
  235.    {0,0,16,16,1, NL ,0,18,NL },
  236.    {0,0,16,16,1, NL ,0,19,NL },
  237.    {0,0,16,16,1, NL ,0,20,NL },
  238.    {0,0,16,16,1, NL ,0,21,NL },
  239.    {0,0,16,16,1, NL ,0,22,NL },
  240.    {0,0,16,16,1, NL ,0,23,NL },
  241.    {0,0,16,16,1, NL ,0,24,NL },
  242.    {0,0,16,16,1, NL ,0,25,NL },
  243.    {0,0,16,16,1, NL ,0,26,NL },
  244.    {0,0,16,16,1, NL ,0,27,NL },
  245.    {0,0,16,16,1, NL ,0,28,NL },
  246.    {0,0,16,16,1, NL ,0,29,NL },
  247.    {0,0,16,16,1, NL ,0,30,NL },
  248.    {0,0,16,16,1, NL ,0,31,NL } };
  249.  
  250. struct Gadget palg[CTSIZ] = {
  251.    { &palg[1], 3, 3,  16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  252.       BOOLGADGET,  (APTR)&m3C[0], NL,NL,NL,NL, PGAD+0, NL},
  253.    { &palg[2], 19,3, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  254.       BOOLGADGET,  (APTR)&m3C[1], NL,NL,NL,NL, PGAD+1, NL},
  255.    { &palg[3], 35,3, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  256.       BOOLGADGET,  (APTR)&m3C[2], NL,NL,NL,NL, PGAD+2, NL},
  257.    { &palg[4], 51,3, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  258.       BOOLGADGET,  (APTR)&m3C[3], NL,NL,NL,NL, PGAD+3, NL},
  259.    { &palg[5], 67,3, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  260.       BOOLGADGET,  (APTR)&m3C[4], NL,NL,NL,NL, PGAD+4, NL},
  261.    { &palg[6], 83,3, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  262.       BOOLGADGET,  (APTR)&m3C[5], NL,NL,NL,NL, PGAD+5, NL},
  263.    { &palg[7], 99,3, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  264.       BOOLGADGET,  (APTR)&m3C[6], NL,NL,NL,NL, PGAD+6, NL},
  265.    { &palg[8],115,3,  16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  266.       BOOLGADGET,  (APTR)&m3C[7], NL,NL,NL,NL, PGAD+7, NL},
  267.    { &palg[9], 3,19, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  268.       BOOLGADGET,  (APTR)&m3C[8], NL,NL,NL,NL, PGAD+8, NL},
  269.    { &palg[10],19,19, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  270.       BOOLGADGET,  (APTR)&m3C[9], NL,NL,NL,NL, PGAD+9, NL},
  271.    { &palg[11],35,19, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  272.       BOOLGADGET,  (APTR)&m3C[10], NL,NL,NL,NL, PGAD+10, NL},
  273.    { &palg[12],51,19, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  274.       BOOLGADGET,  (APTR)&m3C[11], NL,NL,NL,NL, PGAD+11, NL},
  275.    { &palg[13],67,19, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  276.       BOOLGADGET,  (APTR)&m3C[12], NL,NL,NL,NL, PGAD+12, NL},
  277.    { &palg[14],83,19, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  278.       BOOLGADGET,  (APTR)&m3C[13], NL,NL,NL,NL, PGAD+13, NL},
  279.    { &palg[15],99,19,16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  280.       BOOLGADGET,  (APTR)&m3C[14], NL,NL,NL,NL, PGAD+14, NL},
  281.    { &palg[16],115,19,16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  282.       BOOLGADGET,  (APTR)&m3C[15], NL,NL,NL,NL, PGAD+15, NL},
  283.    { &palg[17], 3,35, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  284.       BOOLGADGET, (APTR)&m3C[16], NL,NL,NL,NL, PGAD+16, NL},
  285.    { &palg[18],19,35, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  286.       BOOLGADGET,  (APTR)&m3C[17], NL,NL,NL,NL, PGAD+17, NL},
  287.    { &palg[19],35,35, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  288.       BOOLGADGET,  (APTR)&m3C[18], NL,NL,NL,NL, PGAD+18, NL},
  289.    { &palg[20],51,35, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  290.       BOOLGADGET,  (APTR)&m3C[19], NL,NL,NL,NL, PGAD+19, NL},
  291.    { &palg[21],67,35, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  292.       BOOLGADGET,  (APTR)&m3C[20], NL,NL,NL,NL, PGAD+20, NL},
  293.    { &palg[22],83,35, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  294.       BOOLGADGET,  (APTR)&m3C[21], NL,NL,NL,NL, PGAD+21, NL},
  295.    { &palg[23],99,35,16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  296.       BOOLGADGET,  (APTR)&m3C[22], NL,NL,NL,NL, PGAD+22, NL},
  297.    { &palg[24],115,35,16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  298.       BOOLGADGET,  (APTR)&m3C[23], NL,NL,NL,NL, PGAD+23, NL},
  299.    { &palg[25], 3,51, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  300.       BOOLGADGET, (APTR)&m3C[24], NL,NL,NL,NL, PGAD+24, NL},
  301.    { &palg[26],19,51, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  302.       BOOLGADGET,  (APTR)&m3C[25], NL,NL,NL,NL, PGAD+25, NL},
  303.    { &palg[27],35,51, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  304.       BOOLGADGET,  (APTR)&m3C[26], NL,NL,NL,NL, PGAD+26, NL},
  305.    { &palg[28],51,51, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  306.       BOOLGADGET,  (APTR)&m3C[27], NL,NL,NL,NL, PGAD+27, NL},
  307.    { &palg[29],67,51, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  308.       BOOLGADGET,  (APTR)&m3C[28], NL,NL,NL,NL, PGAD+28, NL},
  309.    { &palg[30],83,51, 16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  310.       BOOLGADGET,  (APTR)&m3C[29], NL,NL,NL,NL, PGAD+29, NL},
  311.    { &palg[31],99,51,16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  312.       BOOLGADGET,  (APTR)&m3C[30], NL,NL,NL,NL, PGAD+30, NL},
  313.    { &ok_gad, 115,51,16,16, GADGHBOX | GADGIMAGE, RELVERIFY,
  314.       BOOLGADGET,  (APTR)&m3C[31], NL,NL,NL,NL, PGAD+31, NL} };
  315.  
  316.  
  317. /* Used to open a Window   */
  318. struct NewWindow NewCmod = {
  319.    40,30, PLX,PLY, 2,BCOL, NL,    /* IDCMP set up AFTER CALL */
  320.    ACTIVATE | SMART_REFRESH,
  321.    &palg[0],NL, NL,    /* FirstGadget, CheckMark, Title  */
  322.    NL,NL,              /* MUST SET SCREEN AFTER OPENSCREEN!!! */
  323.    PLX,PLY,PLX,PLY, CUSTOMSCREEN }; /* MinW, MinH, MaxW, MaxH */
  324.  
  325.  
  326. /********************************************************************
  327. * palette(window)
  328. *    This is the meat. This routine opens the palette window and
  329. * retains control until the user selects the OK or CANCEL gadget.
  330. *     The calling arguement is a window pointer.  That window
  331. * is expected to have opened an IDCMP port, which palette uses.
  332. ********************************************************************/
  333. palette(calling_window)
  334. struct Window *calling_window;
  335. {
  336. struct Window *cW;      /* Palette window handle   */
  337.  
  338. FAST struct IntuiMessage *imsg;
  339. FAST struct Gadget *igad;
  340.  
  341. FAST int class,cursel;
  342. BOOL keepon,munge;
  343.  
  344. USHORT backup[CTSIZ];         /* This table restores calling colors... */
  345.  
  346. static char hxtab[16] = { '0','1','2','3','4','5','6','7','8',
  347.    '9','a','b','c','d','e','f' };
  348.  
  349.    for ( cursel=CTSIZ-1; cursel >= 0; cursel--)
  350.       backup[cursel] = p_ct[cursel];
  351.  
  352.    r_prop.Flags = g_prop.Flags = b_prop.Flags = FREEHORIZ | AUTOKNOB;
  353.    r_prop.HorizBody = g_prop.HorizBody = b_prop.HorizBody = 0x1000;
  354.  
  355.    /* Get screen from calling window   */
  356.    NewCmod.Screen = calling_window->WScreen;  /* NEED TO SET SCREEN!!! */
  357.    if ( ! (cW = (struct Window *)OpenWindow(&NewCmod)) ) {
  358.       return(FALSE); /* Oops...  */
  359.       }
  360.  
  361.    PrintIText(cW->RPort,&mstxt,7,71);
  362.  
  363.    cW->UserPort = calling_window->UserPort;
  364.    ModifyIDCMP(cW, GADGETUP | GADGETDOWN | MENUVERIFY );
  365.  
  366.    for ( munge = keepon = TRUE; keepon; ) {
  367.  
  368.       if ( munge ) {
  369.          SetAPen(cW->RPort,cursel);
  370.          RectFill(cW->RPort,133,3,PLX-5,66);
  371.  
  372.          /* RJ will proably cringe if he see's this, but it is proably */
  373.          /* safe to modify the HorizPot values this way, UNLESS the    */
  374.          /* gadgets were being fiddled with when you do it. Here that  */
  375.          /* is quite unlikely, since another gadget was just activated */
  376.          /* to cause the munge flag to be set...                       */
  377.  
  378.          r_prop.HorizPot = (p_ct[cursel] & 0xf00) << 4;
  379.          g_prop.HorizPot = (p_ct[cursel] & 0x0f0) << 8;
  380.          b_prop.HorizPot = p_ct[cursel] << 12;
  381.          RefreshGadgets(&red_gad,cW,NL);
  382.          munge = FALSE;
  383.          hxtxt.FrontPen = cursel ^ 15;
  384.          hxtxt.BackPen  = cursel;
  385.          }
  386.  
  387.       while ( ! (imsg=(struct IntuiMessage *)GetMsg(cW->UserPort)) ) {
  388.          class = p_ct[cursel] = ((r_prop.HorizPot >> 4) & 0xf00) +
  389.             ((g_prop.HorizPot >> 8) & 0xf0) + (b_prop.HorizPot >>12);
  390.          set_cmap();
  391.  
  392.          frog[0] = hxtab[class >> 8];
  393.          frog[1] = hxtab[ (class >> 4) & 0x0f];
  394.          frog[2] = hxtab[class & 0x0f];
  395.          PrintIText(cW->RPort,&hxtxt,0,0);
  396.  
  397.          /* Proably, should do a WaitPort(cW->UserPort); */
  398.          /* I didn't, so the color updates faster.       */
  399.          /* In a multitasking environment, the system is */
  400.          /* being gronked...                             */
  401.          }
  402.  
  403.       igad =(struct Gadget *) imsg->IAddress;
  404.       if ( (class = imsg->Class) == MENUVERIFY ) {
  405.          imsg->Code = MENUCANCEL;      /* Don't Let Em Out! */
  406.          DisplayBeep(NL);
  407.          }
  408.       ReplyMsg(imsg);
  409.  
  410.       switch ( class ) {
  411.          case GADGETUP:
  412.          case GADGETDOWN:
  413.             if ((igad->GadgetID >= PGAD)&&(igad->GadgetID < PGAD+CTSIZ)) {
  414.                cursel = igad->GadgetID - PGAD;
  415.                munge = TRUE;
  416.                }
  417.             else switch ( igad->GadgetID ) {
  418.                case PGHI+1:      /* Cancel   */
  419.                   for ( class =0 ; class<CTSIZ; class++)
  420.                      p_ct[class] = backup[class];
  421.                   set_cmap();
  422.                case PGHI:        /* OK */
  423.                   keepon = FALSE;
  424.                   break;
  425.  
  426.                case PGHI+2:      /* Reset */
  427.                   set_defmap();
  428.                   munge = TRUE;
  429.                   break;
  430.                }
  431.          }
  432.       }
  433.  
  434.    cW->UserPort = NL;
  435.    CloseWindow(cW);
  436.    return(TRUE);
  437. }
  438.  
  439.  
  440. /*************************************************************/
  441.  
  442. main()
  443. {
  444. init_program();
  445. palette(p_W);
  446. clear_program();
  447. }
  448.  
  449. /*** End of MicroSmith's Palette Tool  ***/
  450.  
  451.